Skip to content

Set TIFF DPI from volume voxel size#785

Open
SuperOptimizer wants to merge 5 commits intoScrollPrize:mainfrom
SuperOptimizer:tiff_dpi2
Open

Set TIFF DPI from volume voxel size#785
SuperOptimizer wants to merge 5 commits intoScrollPrize:mainfrom
SuperOptimizer:tiff_dpi2

Conversation

@SuperOptimizer
Copy link
Copy Markdown
Contributor

@SuperOptimizer SuperOptimizer commented Mar 6, 2026

Summary

  • Derives DPI from voxelsize metadata (25400 / voxelSize_µm) and embeds it in TIFF output via TIFFTAG_XRESOLUTION/TIFFTAG_YRESOLUTION tags
  • Adds voxelSizeToDpi() helper and optional dpi parameter to writeTiff()/TiffWriter
  • Propagates resolution tags through mergeTiffParts
  • Sets DPI on QuadSurface from tracer/grower voxelsize so all saved segment TIFFs get correct resolution
  • Reads voxelsize from meta.json in vc_zarr_to_tiff and vc_render_tifxyz

Test plan

  • Build and verify no regressions
  • Run vc_zarr_to_tiff on a volume with known voxelsize, verify output TIFFs have correct DPI via tiffinfo
  • Grow a segment and verify saved x/y/z.tif files have DPI set
  • Render with vc_render_tifxyz and verify output TIFFs have DPI set

🤖 Generated with Claude Code

SuperOptimizer and others added 5 commits March 5, 2026 07:57
Derive DPI from voxelsize metadata (25400 µm/inch ÷ voxelSize µm = DPI)
and embed it in TIFF output via XRESOLUTION/YRESOLUTION tags.

- Add voxelSizeToDpi() helper and optional dpi parameter to writeTiff/TiffWriter
- Propagate resolution tags through mergeTiffParts
- Set dpi on QuadSurface from tracer/grower voxelsize
- Read voxelsize from meta.json in vc_zarr_to_tiff and vc_render_tifxyz

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 6, 2026

@SuperOptimizer is attempting to deploy a commit to the scroll Team on Vercel.

A member of the Team first needs to authorize it.

@giorgioangel
Copy link
Copy Markdown
Member

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf63f528fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +71 to +72
double vs = meta["voxelsize"].get<double>();
dpi = voxelSizeToDpi(vs);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scale DPI by selected pyramid level

vc_zarr_to_tiff reads from dataset input/<level> but computes DPI from the base meta.json voxel size without applying the level downsampling factor, so outputs from --level > 0 are tagged with overly high resolution. The repo’s volume docs explicitly define levels as 2x/4x/8x downsampled (volume-cartographer/docs/api/Volume.md, lines 135-137 and 173), so this writes incorrect physical calibration metadata for nonzero levels and can distort downstream measurements.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a good point.

Comment on lines +1307 to +1308
double vs = meta["voxelsize"].get<double>();
tifDpi = voxelSizeToDpi(vs);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Account for group index when setting render DPI

In vc_render_tifxyz, DPI is derived from raw voxelsize only, but render resolution already changes with group_idx via ds_scale = 2^-group_idx (same file, lines 1258 and 1458), so any run with --group-idx > 0 gets TIFF resolution tags that are too high for the generated pixel grid. This produces inconsistent spatial metadata between rendered outputs from different OME-Zarr levels.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants